From fdcac0323be02748822bd1d3675e9315a9f4d7d1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Jul 2014 22:38:30 -0700 Subject: [PATCH] Canonicalize URLs when hashing sources --- src/cargo/core/source.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 6284f755a..cb479cd01 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -1,5 +1,6 @@ use std::fmt; use std::fmt::{Show, Formatter}; +use std::hash; use serialize::{Decodable, Decoder, Encodable, Encoder}; use url::Url; @@ -77,7 +78,7 @@ impl> Encodable for Location { } } -#[deriving(Encodable, Decodable, Clone, Eq, Hash)] +#[deriving(Encodable, Decodable, Clone, Eq)] pub struct SourceId { pub kind: SourceKind, pub location: Location, @@ -145,6 +146,24 @@ impl PartialEq for SourceId { } } +impl hash::Hash for SourceId { + fn hash(&self, into: &mut S) { + match *self { + SourceId { + kind: ref kind @ GitKind(..), + location: Remote(ref url) + } => { + kind.hash(into); + git::canonicalize_url(url.to_string().as_slice()).hash(into); + } + _ => { + self.kind.hash(into); + self.location.hash(into); + } + } + } +} + impl SourceId { pub fn new(kind: SourceKind, location: Location) -> SourceId { SourceId { kind: kind, location: location } -- 2.30.2